import React,{useState} from 'react'
import { Button, Select } from 'antd';
import { SearchOutlined } from '@ant-design/icons';
import {getAll} from '../../services/shops'

const { Option } = Select;

export default function Search({show}) {
    let [type, setType] = useState('');
    let [value, setValue] = useState('');
    // const [a,setA]=useState("");
    const handleType=(e) => {

       setType(e)

    }
    const handleInput=(e)=> {
        // console.log(e,'1234',e.target);
        setValue(e.target.value)
    }
    const searchBtn=async() => {
        // console.log({type.cont,value:value});
        let {data} = await getAll({type,value});
        console.log(data);
        // 看show里面要的是什么
        show({type,value});
    }
  return (
     
     <div style={{display: 'flex'}}>
     
        <Select  
        defaultValue={'name'}
        onChange={handleType} style={{width:'100px'}} >
            <Option value="name" >商品名</Option>
            <Option value="typeName">分类名</Option>
            <Option value="price">价格</Option>
            <Option value="total">销量</Option>

        </Select>
        <input name='value' type='text' value={value}
            onInput={handleInput}
        
        />
        <Button type="primary" icon={<SearchOutlined />} onClick={searchBtn}>
            搜索
        </Button>
     </div>

  )
}
